<!DOCTYPE html>
<html>
<head>
<title> yukari world</title>
    <meta name="viewport" content="device-width,initial-scale=1.0">
    <link rel = "Shortcut Icon" href="${rc.contextPath}/images/timg.jpeg"/>
    <link rel="stylesheet" type="text/css" href="${rc.contextPath}/bootstrap/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="${rc.contextPath}/css/jquery-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="https://shark.douyucdn.cn/app/douyu/css/page/room-normal/app-all.css?nv=20171114v7.183" />
    <link rel="stylesheet" type="text/css" href="https://shark.douyucdn.cn/app/douyu/css/page/room-normal/app-all2.css?nv=20171114v7.183" />
    <link rel="stylesheet" type="text/css" href="https://shark.douyucdn.cn/app/douyu/css/com/app-all.css?nv=20171114v7.183">
    <link rel="stylesheet" type="text/css" href="${rc.contextPath}/css/danmu_style.css?v=1.2" />
    <link rel="stylesheet" type="text/css" href="${rc.contextPath}/css/liwu_style.css?v=2.2" />

    <script src="${rc.contextPath}/js/jquery-3.1.1.js"></script>
    <script src="${rc.contextPath}/js/jquery-ui.min.js"></script>
    <script src="${rc.contextPath}/js/utils.js?v=1.1"></script>
    <script src="${rc.contextPath}/js/liwu.js?v=2.0"></script>
    <script src="${rc.contextPath}/js/CommentCoreLibrary.js?v=1.2"></script>

<style>

</style>
</head>
<body id="body">

	<div style="float:left;">
		<div>
			<div style="display:inline" class="btn btn-warning btn-sm" onClick="changeServer()">切换服务器</div>
			<div style="display:inline" class="btn btn-info btn-sm" onClick="showLiwuStyleList()">屏蔽礼物</div>
			<div style="display:inline" class="btn btn-danger btn-sm" onClick="closeAll()">关闭所有</div>
            <div style="display:inline" class="btn btn-success btn-sm" onClick="changeShowXiaoma()" id="showXiaomaBtn">飘屏已开</div>
			<div style="display:inline" class="btn btn-info btn-sm" onClick="callXiaoma()">呼叫小马</div>
			<div style="display:inline" class="btn btn-primary btn-sm" onClick="changeDanmuji(0)" id="danmujiBtn">弹幕机已关</div>
			<!--<div class="btn btn-success btn-sm" onClick="playAudioLiwuAll()">感谢所有</div>-->
		</div>
		<div>
			<div style="margin:5px 0;display:inline"><span>首页监控: </span><div id="homePageStatus" class="btn-danger btn-sm" style="display:inline">否</div></div>
            <div style="margin:5px 0;display:inline" onclick="getRoomRank()"><span>热度值: </span><div id="online" class="btn-success btn-sm" style="display:inline" onmousemove="showOllineNum()" onmouseout="hideOllineNum()">0</div></div>
            <div style="margin:5px 0;display:inline" >
                字体大小: <input type="text" id="chatmsgFontSize" name="chatmsgFontSize" value="13" style="width: 30px;"/>px
                <a class="btn btn-primary btn-sm" href="javascript:reloadXiaomaDanmu()">刷新</a>
                <a class="btn btn-primary btn-sm" href="javascript:openXiaomaDanmu()">打开</a>
                <a class="btn btn-success btn-sm" href="javascript:openThumb()">封面</a>
            </div>
		</div>
		<div>
			<div>
				<input type="text" id="str" name="str"/>
				<a class="glyphicon glyphicon-volume-up" href="javascript:bofang()"></a>
				<select id="audioSpd"><option selected>1</option><option>2</option><option>3</option><option selected="selected">4</option><option>5</option><option>6</option><option>7</option></select>
				<select id="audioLan"><option value="zh">中文</option><option value="en">英式</option><option value="uk">美式</option><option value="cte">粤语</option></select>
				<select id="audioContent"><option value="mz">只读名字</option><option value="gx">感谢礼物</option></select>
				<a class="btn btn-primary btn-sm" href="javascript:getPinyin()">翻译拼音</a>
				<a class="btn btn-primary btn-sm" href="javascript:getYinbiao()">获取音标</a>
				<a class="btn btn-primary btn-sm" href="javascript:getChatmsg()">弹幕查询</a>
				<span id="pinyin" class="pinyin"></span>
			</div>
		</div>
		<div>
			<table id="liwuTable">

			</table>
		</div>
	</div>
	<div class="chatmsg" id="chatmsg" style="display: none;">
        <div id="tabDiv">
            <ul class="nav nav-tabs">
                <li id="chatmsg-ul-change-key">
                    <a onclick="window.frames['chatmsgHtml'].tabChange('chatmsg-ul')" data-toggle="tab">
                        弹幕
                    </a>
                </li>
                <li id="uenter-ul-change-key">
                    <a onclick="window.frames['chatmsgHtml'].tabChange('concern-ul')" data-toggle="tab">
                        关注人
                    </a>
                </li>
            </ul>
        </div>
		<iframe src="" class="chatmsgHtml" name="chatmsgHtml" id="chatmsgHtml"></iframe>
	</div>
	<div class="showTalk" onclick="javascript:$('.showTalk').hide()">
		<div class="authTalk" id="authTalk" >
		</div>
	</div>
</body>
<script>
    var cm;
    var hideLiwuStyleIds = [0<#list hideIds as hideId>,${hideId}</#list>];
$(document).ready(function() {
    $("body").height(window.innerHeight);
	showLiwu(-1);
	setInterval("showLiwu(20)",2000);
	getRoomStatus();
	setInterval("getRoomStatus()",30000);
	if (window.Notification) {
		setInterval("getImportantMessage()",5000);
	}
	$(authTalk).click(function(event){event.stopPropagation()});
	var c = $("#chatmsg");
	c.css("height",$(window).height()*0.8);
	c.css("width",$(window).width()/4);

    cm = new CommentManager(document.getElementById("body"));
    cm.init();
    cm.start();
    if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|SymbianOS)/i))) {
        //移动端拖动
        var indexbtn = document.getElementById("chatmsg");
        indexbtn.addEventListener('touchstart',touch,false);
        indexbtn.addEventListener('touchmove',touch,false);
        indexbtn.addEventListener('touchend',touch,false);
        var x,y;
        function touch(event){
            var event = event || window.event;
            switch(event.type){
                case "touchstart":
                    x = parseInt(event.touches[0].clientX);
                    y = parseInt(event.touches[0].clientY);
                    break;
                case "touchend":
                    y =  parseInt(event.changedTouches[0].clientY);
                    x = parseInt(event.changedTouches[0].clientX);
                    indexbtn.style.top = y+"px";
                    indexbtn.style.left = x+"px";
                    break;
                case "touchmove":
                    y =  parseInt(event.touches[0].clientY);
                    x = parseInt(event.touches[0].clientX);
                    indexbtn.style.top = y+"px";
                    indexbtn.style.left = x+"px";
                    break;
            }
        }
    } else {
        c.draggable();
        c.resizable();
    }
    //临时增加

});


    function shieldAuth(authId){
        var d = prompt("屏蔽天数?","7");
        if (d==""){
            alert("请输入屏蔽天数");
            return;
        }
        if (d){
            if (!isNaN(d)){
                $.ajax({
                    'url':'${rc.contextPath}/admin/shield/auth/add',
                    'dataType':'json',
                    'data':{"authId":authId,"day":d},
                    'type': 'POST',
                    'success':function(data){
                        if(data.code == 0){
                            $("#banMessage").html(data.message);
                        }
                    },
                    'error':function(){
                    }
                });
            } else {
                alert("请输入正确数字");
            }
        }

    }


function banAuth(authId){
    if(confirm("是否禁言30天?")){
        $.ajax({
            'url':'${rc.contextPath}/admin/ban/byLiwu',
            'dataType':'json',
            'data':{"authId":authId},
            'type': 'POST',
            'success':function(data){
                if(data.code == 0){
                    $("#banMessage").html(data.message);
                }
            },
            'error':function(){
            }
        });
    }
}

function showLiwuStyleList(){
    var trs = $("#liwuTable tr");
    var liwuStyles = {};
    for(var i=0;i<trs.length;i++){
        var tr = trs.eq(i);
        if(!liwuStyles[tr.attr("liwu-style-id")]){
            var name = tr.find(".name").html();
            if(!name){
                name = tr.find(".noble-name").html();
            }
            liwuStyles[tr.attr("liwu-style-id")] = name;
        }
    }
    var talkDiv = $("#authTalk");
    talkDiv.html("");
    talkDiv.append('<div class="btn btn-primary btn-sm" style="display: block" onClick="changeShowHideLiwuStyleAll()">永久保存</div>')
    for(var k in liwuStyles){
        var div = $('<div class="talkTxt"></div>')
        var input = $('<input type="checkbox" value="'+k+'" checked="checked" onchange="changeShowHideLiwuStyle(this)">')
        for(var i=1;i<hideLiwuStyleIds.length;i++){
            if (hideLiwuStyleIds[i] == k){
                input.prop("checked",false);
                break;
            }
        }
        var span = $('<span>'+liwuStyles[k]+'</span>');
        div.append(input);
        div.append(span);
        talkDiv.append(div);
    }
    $(".showTalk").show();
}

function changeShowHideLiwuStyle(a){
    var va = $(a);
    var vv = parseInt(va.val())
    if(va.prop("checked")){
        for(var i=1;i<hideLiwuStyleIds.length;i++){
            if (hideLiwuStyleIds[i] == vv){
                hideLiwuStyleIds.splice(i,1);
                break;
            }
        }
        $("#liwuTable tr[liwu-style-id="+vv+"]").show();
    } else {
        $("#liwuTable tr[liwu-style-id="+vv+"]").hide();
        hideLiwuStyleIds[hideLiwuStyleIds.length] = vv;
    }
}
function changeShowHideLiwuStyleAll(){
    $.ajax({
        'url':'${rc.contextPath}/admin/douyu/setHideIds',
        'dataType':'json',
        'data' :  {'ids':hideLiwuStyleIds},
        traditional:true,
        'type': 'POST',
        'success':function(data){
        }
    });
}

var showLiwuFlag = true;
function showLiwu(size){
    if (showLiwuFlag) {
        showLiwuFlag = false;
        $.ajax({
            'url':'${rc.contextPath}/admin/douyu/getLiwu',
            'dataType':'json',
            'data' :  {'size':size},
            'type': 'POST',
            'success':function(data){
                forFlag = true;
                if (showFlag){
                    for(var i=data.length-1;i>=0;i--){
                        addTr(data[i]);
                    }
                    showFlag = false;
                } else {
                    for(var i=0;i<data.length;i++){
                        addTr(data[i]);
                        if (!forFlag){
                            break;
                        }
                    }
                }
                showLiwuFlag = true;
            },
            'error':function(){
                showLiwuFlag = true;
            }
        });
    }
}


function getChatmsg(){
    var str = $("#str").val();
    $.ajax({
        'url':'${rc.contextPath}/admin/chatmsg/find',
        'data':{'name':str,'fuzzy':true},
        'dataType':'json',
        'type': 'POST',
        'success':function(data){
            if (data.code == 0){
                var json = data.data;
                var talkDiv = $("#authTalk");
                talkDiv.text("");
                for(var i=0;i<json.length;i++){
                    var talk = json[i];
                    talkDiv.append($('<div class="talkTxt">['+formatDate(talk.time)+'] <a href="javascript:getAuthTalk('+talk.id+')">'+talk.name+'</a> : '+chatmsgReplace(talk.txt)+'</div>'))
                }
                $(".showTalk").show();
            } else {
                alert(data.message);
            }
        }
    });
}


function getAuthDetail(id){
    var str = $("#str").val();
    $.ajax({
        'url':'${rc.contextPath}/admin/auth/detail',
        'data':{'authId':id},
        'dataType':'json',
        'type': 'POST',
        'success':function(data){
            if (data.code == 0){
                var json = data.data;
                var talkDiv = $("#authTalk");
                talkDiv.text("");
                var t = $("<table style='line-height: 30px;'></table>");
                t.append($("<tr><td style='width: 100px'><strong>名字</strong></td><td colspan='2'>"+json.name+"</td></tr>"));
                t.append($("<tr><td><strong>等级</strong></td><td colspan='2'>"+json.lv+"</td></tr>"));
                t.append($("<tr><td><strong>196粉丝牌</strong></td><td colspan='2'>"+json.fansLv+"</td></tr>"));
                t.append($("<tr><td><strong>贵族</strong></td><td colspan='2'>"+json.guizu+"</td></tr>"));
                for (var i=0;i<json.oldNames.length;i++){
                    if (i==0){
                        t.append($("<tr><td><strong>曾用名</strong></td><td colspan='2'>"+json.oldNames[i]+"</td></tr>"));
                    } else {
                        t.append($("<tr><td></td><td colspan='2'>"+json.oldNames[i]+"</td></tr>"));
                    }
                }
                t.append($("<tr><td><strong>粉丝牌</strong></td><td><strong>牌子</strong></td><td><strong>等级</strong></td></tr>"));
                for (var i=0;i<json.badges.length;i++){
                    t.append($("<tr><td></td><td>"+json.badges[i].name+"</td><td>"+json.badges[i].lv+"</td></tr>"));
                }
                talkDiv.append(t);
                $(".showTalk").show();
            } else {
                alert(data.message);
            }
        }
    });
}

function getAuthTalk(id){
    $.ajax({
        'url':'${rc.contextPath}/admin/chatmsg/getAuthTalk',
        'data':{'authId':id},
        'dataType':'json',
        'type': 'POST',
        'success':function(data){
            if (data.code == 0){
                var json = data.data;
                var name = json.name;
                var talkDiv = $("#authTalk");
                talkDiv.text("");
                talkDiv.append(($('<div><a class="btn btn-sm btn-danger" href="javascript:" onclick="banAuth('+id+')">禁言30天</a><a class="btn btn-sm btn-warning" href="javascript:" onclick="shieldAuth('+id+')">屏蔽弹幕</a><a class="btn btn-sm btn-success" href="javascript:" onclick="getAuthDetail('+id+')">用户详情</a><span id="banMessage" style="color: red;"></span></div>')))
                for(var i=0;i<json.talkList.length;i++){
                    var talk = json.talkList[i];
                    talkDiv.append($('<div class="talkTxt">['+formatDate(talk.time)+'] '+name+' : '+chatmsgReplace(talk.txt)+'</div>'))
                }
                $(".showTalk").show();
            } else {
                alert(data.message);
            }
        }
    });
}


function closeLiwu(data){
    $.ajax({
        'url':'${rc.contextPath}/admin/douyu/closeLiwu',
        'data':$.param(data,true),
        'dataType':'json',
        'type': 'POST',
        'async': false,
        'success':function(message){
            return message.code;
        }
    });
}



    function reloadXiaomaDanmu(){
        var size = $("#chatmsgFontSize").val();
        $("#chatmsgHtml").attr("src","${rc.contextPath}/admin/douyu/chatmsg?fontSize="+size);
        $("#danmujiBtn").html("小马弹幕机");
        $("#danmujiBtn").attr("onClick","changeDanmuji(1)");
        $("#tabDiv").show();
        $("#chatmsg").show();
    }
    
    function openXiaomaDanmu() {
        var size = $("#chatmsgFontSize").val();
        window.open("${rc.contextPath}/admin/douyu/chatmsg?fontSize="+size,"_blank");
    }

    function changeDanmuji(i){
    if(i == 0){
        $("#chatmsgHtml").attr("src","${rc.contextPath}/admin/douyu/chatmsg");
        $("#danmujiBtn").html("小马弹幕机");
        $("#danmujiBtn").attr("onClick","changeDanmuji(1)");
        $("#tabDiv").show();
        $("#chatmsg").show();
	} else if(i == 1) {
        $("#chatmsgHtml").attr("src","https://yukari.top/yukari/danmu3.php");
        $("#danmujiBtn").html("香香弹幕机");
        $("#danmujiBtn").attr("onClick","changeDanmuji(2)");
        $("#tabDiv").hide();
        $("#chatmsg").show();
	} else if (i == 2){
        $("#chatmsgHtml").attr("src","");
        $("#danmujiBtn").html("弹幕机已关");
        $("#danmujiBtn").attr("onClick","changeDanmuji(0)");
        $("#tabDiv").hide();
        $("#chatmsg").hide();
        cm.clear();
	}
}


var lastMessageId = ${xmMessage.id};
var messageFlag = true;
function getImportantMessage(){
	if (messageFlag){
		messageFlag = false;
		$.ajax({
			'url':'${rc.contextPath}/admin/douyu/getXmMessage',
			'dataType':'json',
			'type': 'POST',
			'success':function(json){
				if (json.data.id > lastMessageId){
                    lastMessageId = json.data.id;
					Notification.requestPermission(function(status) {
						var n = new Notification('小马提示', { body: json.data.message });
					});
					addMessageTr(json.data);
				}
				messageFlag = true;
			},
			'error':function(){
				messageFlag = true;
			}
		});
	}
}

function addMessageTr(data){
    var liwuTable = document.getElementById("liwuTable");
    var tr = document.createElement("tr");
    var td1 = document.createElement("td");
    td1.className="message";
    var span1 = document.createElement("span");
    span1.innerHTML="小马提示：";
    span1.style.color="red";
    var span2 = document.createElement("span");
    span2.innerHTML=data.message;
    td1.appendChild(span1);
    td1.appendChild(span2);
    tr.appendChild(td1);
    liwuTable.insertBefore(tr,liwuTable.firstChild);
}


function getYinbiao(){
	var str = $("#str").val();
	$.ajax({
		'url':'${rc.contextPath}/admin/fanyi/enToZh',
		'dataType':'json',
		'data' :  {'txt':str},
		'type': 'POST',
		'success':function(json){
			if (json.code == 0){
				$("#pinyin").html(json.data);
			} else {
				$("#pinyin").html(json.message);
			}
		}
	});
}

function bofang(){
	var str = $("#str").val();
	var spd = $("#audioSpd option:selected").html();
	var lan = $("#audioLan option:selected").val();
	if (str){
		var url = "http://fanyi.baidu.com/gettts?lan="+lan+"&text="+encodeURI(str)+"&spd="+spd+"&source=web";
		playAudio(url);
	}
}

function playAudioLiwuAll(){
	alert("敬请期待");
}
function playAudioLiwu(name,liwu){
	var txt = "";
	if ($("#audioContent option:selected").val() == "gx"){
		txt = "感谢"+name+"的"+liwu;
	} else {
		txt = name;
	}
	var spd = $("#audioSpd option:selected").html();
	var lan = $("#audioLan option:selected").val();
	var url = "http://fanyi.baidu.com/gettts?lan="+lan+"&text="+encodeURI(txt)+"&spd="+spd+"&source=web";
    playAudio(url);
}

function playAudio(url){
	var audio = document.createElement('audio');
    var source = document.createElement('source');   
    source.type = "audio/mpeg";
    source.type = "audio/mpeg";
    source.src = url;   
    source.autoplay = "autoplay";
    source.controls = "controls";
    audio.appendChild(source); 
    audio.play();
}



var changeServerFlag = true;
function changeServer(){
	if (changeServerFlag){
		changeServerFlag = false;
		$.ajax({
			'url':'${rc.contextPath}/admin/douyu/changeServer',
			'dataType':'json',
			'type': 'POST',
			'success':function(json){
				if (json.code == 0){
					alert("切换成功:"+json.data);
				}
			},
            'error':function(){
			    alert('切换失败');
            },
            'complete':function(){
                changeServerFlag = true;
            }
		});
	}
}


    function getRoomRank(){
        $.ajax({
            'url':'${rc.contextPath}/admin/douyu/getRoomRank',
            'dataType':'json',
            'type': 'POST',
            'success':function(json){
               if (json.code == 0){
                   var table = $("<table style='width:100%'><tr style='height: 25px'><td class='td1'>排名</td><td class='td3'>主播</td><td class='td3'>热度</td><td class='td3'>房间号</td></tr></table>");
                   var data = json.data;
                   for(var i=0;i<data.length;i++){
                        var tr = $("<tr></tr>");
                        if (data[i].room_id == 196){
                            tr.css("color","red");
                            tr.css("backgroundColor","yellow");
                        }
                        var td1 = $("<td>"+(i+1)+"</td>");
                        var td2 = $("<td>"+data[i].nickname+"</td>");
                        var td3 = $("<td>"+data[i].hn+"</td>");
                        var td4 = $("<td><a href='https://www.douyu.com/"+data[i].room_id+"' target='_blank'>"+data[i].room_id+"</a></td>");
                        tr.append(td1);
                        tr.append(td2);
                        tr.append(td3);
                        tr.append(td4);
                        table.append(tr);
                   }
                   $("#authTalk").html("");
                   $("#authTalk").append(table);
                   $(".showTalk").show();
               }
            }
        });
    }

function openThumb(){
    window.open(roomThumb);
}
var showFlag = true;
var forFlag = true;
var onlineNum = 0;
var roomThumb = "";
function getRoomStatus(){
	$.ajax({
		'url':'${rc.contextPath}/admin/douyu/getRoomStatus',
		'dataType':'json',
		'type': 'POST',
		'success':function(json){
			var div = $("#homePageStatus");
			if (json.data.homePageStatus){
				div.attr("class","btn-success btn-sm");
				div.html("是");
			} else {
				div.attr("class","btn-danger btn-sm");
				div.html("否");
			}
			onlineNum = json.data.online;
            roomThumb = json.data.thumb;

		}
	});
}

function showOllineNum() {
    $("#online").html(onlineNum);
}

function hideOllineNum() {
    $("#online").html("0");
}

function getPinyin(){
	var str = $("#str").val();
	var data = {"str":[str]};
	$.ajax({
		'url':'${rc.contextPath}/admin/douyu/pinyin',
		'data':$.param(data,true),
		'dataType':'json',
		'type': 'POST',
		'success':function(message){
			var data = message.data;
			var pinyin = " "+data;
			// for(var i=0;i<data.length;i++){
			// 	if (pinyin.indexOf(pinyin.length-1) != " "){
			// 		if (data[i].length > 1){
			// 			pinyin = pinyin + "  ";
			// 		}
			// 	}
			// 	pinyin = pinyin + data[i];
			// 	if (data[i].length > 1){
			// 		pinyin = pinyin + "  ";
			// 	}
			// }
			$("#pinyin").html(pinyin);
		}
	});
}

function callXiaoma(){
	$.ajax({
		'url':'${rc.contextPath}/admin/xiaoma/callXiaoma',
		'data':'',
		'dataType':'json',
		'type': 'POST',
		'success':function(json){
			alert(json.data);
		}
	});
}

var showXiaomaFlag = true;
function changeShowXiaoma(){
    showXiaomaFlag = !showXiaomaFlag;
    var btn = $("#showXiaomaBtn");
    if (showXiaomaFlag){
        btn.removeClass("btn-danger");
        btn.addClass("btn-success");
        btn.html("飘屏已开");
    } else {
        btn.removeClass("btn-success");
        btn.addClass("btn-danger");
        cm.clear()
        btn.html("飘屏已关");
    }
}

function showXiaoma(uid,icon,name,txt,danmuStyle){
    if (showXiaomaFlag) {
        var danmaku = {
            "uid":uid,
            "dur":15000,
            "mode":1,
            "name":name,
            "text":txt,
            "size":20,
            "color":0xffffff,
            "style":danmuStyle,
            "icon":icon
        };
        cm.send(danmaku);
        if (danmuStyle == "guizu"){
            var a = $(".barrage_box:last");
            a.width(a.find("div a").width()+40+a.find("img").length*30);
        } else if(danmuStyle=="horn"){
            var a = $(".horn");
            a.width(70+a.find(".horn_text").width());
        }
    }
}





    function deletePermission(id,pid){
        $.ajax({
            'url':'${rc.contextPath}/admin/permission/deleteAuth',
            'dataType':'json',
            'data' :  {'authId':id,'permissionId':pid},
            'type': 'POST',
            'success':function(data){
                if (data.code == 0){
                    reloadYukariConcern();
                } else {
                    alert(data.message);
                }

            }
        });
    }



    function addLiwuConcern(id){
        $.ajax({
            'url':'${rc.contextPath}/admin/permission/addAuth',
            'dataType':'json',
            'data' :  {'id':id,'permissionId':3},
            'type': 'POST',
            'success':function(data){
                if (data.code == 0){
                    reloadYukariConcern();
                } else {
                    alert(data.message);
                }
            }
        });
    }

    function deleteLiwuConcern(id){
        deletePermission(id,3);
    }

    function addYukariConcern(){
        var name = window.frames['chatmsgHtml'].document.getElementById('yukariConcernName').value;
        $.ajax({
            'url':'${rc.contextPath}/admin/permission/addAuthName',
            'dataType':'json',
            'data' :  {'name':name,'permissionId':2},
            'type': 'POST',
            'success':function(data){
                if (data.code == 0){
                    reloadYukariConcern();
                } else {
                    alert(data.message);
                }
            }
        });
    }

    function deleteYukariConcern(id){
        deletePermission(id,2);
    }

    var sycv = 0;
    function searchYukariConcern(){
        sycv++;
        var v = sycv;
        var name = window.frames['chatmsgHtml'].document.getElementById('yukariConcernName').value;
        var names = window.frames['chatmsgHtml'].document.getElementsByName("auth-name");
        for (var i=0;i<names.length;i++){
            if (v == sycv){
                if (names[i].innerHTML.indexOf(name) >= 0){
                    names[i].parentNode.parentNode.style.display = "block";
                } else {
                    names[i].parentNode.parentNode.style.display = "none";
                }
            } else {
                return;
            }
        }
    }

    function reloadYukariConcern(){
        $.ajax({
            'url':'${rc.contextPath}/admin/permission/getYukariConcern',
            'dataType':'json',
            'data' :  {"permissionId":2},
            'type': 'POST',
            'success':function(json){
                if (json.code == 0){
                    var ul = window.frames['chatmsgHtml'].document.getElementById('concern-ul');
                    var name = window.frames['chatmsgHtml'].document.getElementById('yukariConcernName');
                    var nameVal = '';
                    if (name){
                        nameVal = name.value;
                    }
                    var tli = document.createElement("li");
                    var ip = document.createElement("input");
                    ip.id="yukariConcernName";
                    ip.type="text";
                    ip.oninput = function(){window.parent.searchYukariConcern()};
                    ip.value = nameVal;
                    var a = document.createElement(("a"))
                    a.style.float = "right";
                    a.innerText="添加关注";
                    a.href="javascript:window.parent.addYukariConcern()"
                    tli.style.position = "fixed";
                    tli.style.background = "#f8f8f8";
                    tli.style.width = "100%";
                    tli.appendChild(ip);
                    tli.appendChild(a);
                    ul.innerHTML = "";
                    ul.appendChild(tli);
                    var teli = document.createElement("li");
                    teli.style.height = "22px";
                    ul.appendChild(teli);
                    var data = json.data;
                    var ais = [];
                    if (data){
                        for(var i=0;i<data.length;i++){
                            var li = document.createElement("li");
                            var span1 = document.createElement("span");
                            var a0 = document.createElement("a");
                            a0.href = "javascript:window.parent.getAuthTalk("+data[i].id+")";
                            a0.innerHTML=data[i].name;
                            a0.name = "auth-name";
                            var span2 = document.createElement("span");
                            var a1 = document.createElement("a");
                            var a2 = document.createElement("a");
                            if (data[i].liwu){
                                a1.innerHTML="取关礼物";
                                a1.href = "javascript:window.parent.deleteLiwuConcern("+data[i].id+")";
                                a2.href = "javascript:window.parent.deleteYukariConcern("+data[i].id+");window.parent.deleteLiwuConcern("+data[i].id+");";
                            } else {
                                a1.innerHTML="关注礼物";
                                a1.href = "javascript:window.parent.addLiwuConcern("+data[i].id+")";
                                a2.href = "javascript:window.parent.deleteYukariConcern("+data[i].id+")";
                            }
                            a2.innerHTML="取消关注";

                            a2.style.marginLeft="2px";
                            span2.style.float = "right";
                            span1.appendChild(a0);
                            span2.appendChild(a1);
                            span2.appendChild(a2);
                            li.appendChild(span1);
                            li.appendChild(span2);
                            if (nameVal != ''){
                                if (data[i].name.indexOf(nameVal) < 0){
                                    li.style.display = "none";
                                }
                            }
                            ul.appendChild(li);
                            ais[i] = data[i].id;
                        }
                        window.frames['chatmsgHtml'].yukari_concern_ids = ais;
                    }
                } else {
                    alert(json.message);
                }


            }
        });
    }

</script>